package 游戏次数;
/*
猜数字游戏
 */

import java.util.Random;
import java.util.Scanner;

public class GameTest {
    public static void start(){
        Random r=new Random();
        int number=r.nextInt(100)+1;

        while(true){
            Scanner sc=new Scanner(System.in);
            System.out.println("输入你想猜的数字：");
            int guessNumber =sc.nextInt();

            //比较输入的数字和系统产生的数据，需要使用分支语句。这使用if...else...if...的格式
            if(guessNumber>number){
                System.out.println("您猜"+guessNumber+"大了");
            }else if (guessNumber<number) {
                System.out.println("您猜的"+guessNumber+"小了");
            }else if (guessNumber==number){
                System.out.println("恭喜你，您猜对了");
                break;
            }
        }
    }
}
